package zx.lrn.notes.basic_grammer.interfaces_proxy;

import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.stream.IntStream;

/**
 * @ClassName: ProxuTest
 * @Description: 代理类测试代码
 * @Author: zhaoxuan
 * @Date: 2020/3/2 22:43
 **/
public class ProxyTest {
    public static void main(String[] args) {
        Object[] arr = IntStream.rangeClosed(1, 1000)
            .mapToObj(e -> Proxy.newProxyInstance(null, Integer.class.getInterfaces(), new ProxyLogic(e))).toArray();
        System.out.println(Arrays.binarySearch(arr, 613));

        Comparable stringA =
            (Comparable)Proxy.newProxyInstance(null, new Class[] {Comparable.class}, new ProxyLogic("abcb"));
        System.out.println(stringA.compareTo("abca"));
    }
}
